home *** CD-ROM | disk | FTP | other *** search
/ In Focus Guide to Better Photography / In Focus Guide to Better Photography.iso / handbook.dxr / 00004.ls < prev    next >
Encoding:
Text File  |  1997-11-05  |  13.8 KB  |  456 lines

  1. global gShowPhotoHiliteText, gFileNameList, gBackButtonHandler, gColorBlack, gGraphicHiliteColor, gSearchHiliteColor, gMyScrollObj, gNeedToCallSearch, gSearchChapterOnly, gGlossScrollObj, gFirstTimeInHandBook, gSearchTextSpriteNum, gSearchTextCastNum, gReturnFromHelpFromHandBookText, gTextFileNameIndex, gNeedToDisposeScroll, gColorOfLastFind, gGlosBoxUpTime, gLastSearchKey, gLastSearchLoc, gSearchKeyChanged
  2.  
  3. on startMovie
  4.   initForEachMovie(#HANDBOOK)
  5.   if the machineType >= 256 then
  6.     set gSearchTextSpriteNum to 45
  7.     set gSearchTextCastNum to 93
  8.   else
  9.     set gSearchTextSpriteNum to 44
  10.     set gSearchTextCastNum to 9
  11.   end if
  12.   creategFileNameList()
  13.   setMarkerList()
  14.   initTypeAheadIndexes()
  15.   set gShowPhotoHiliteText to the text of cast "showPhotoText"
  16.   set gBackButtonHandler to "returnFromText"
  17.   set gSearchChapterOnly to 1
  18.   set gNeedToDisposeScroll to EMPTY
  19.   preLoadRange(44, 45, 1)
  20.   set the textHeight of member 19 to 14
  21.   set the textHeight of member 56 to 15
  22.   set the text of cast "displayText" to "dummy"
  23.   set gGlosBoxUpTime to 0
  24. end
  25.  
  26. on stopMovie
  27.   if not voidp(gMyScrollObj) and objectp(gMyScrollObj) then
  28.     disposeScroll(gMyScrollObj)
  29.     set gMyScrollObj to EMPTY
  30.   end if
  31.   if not voidp(gGlossScrollObj) and objectp(gGlossScrollObj) then
  32.     disposeScroll(gGlossScrollObj)
  33.     set gGlossScrollObj to EMPTY
  34.   end if
  35. end
  36.  
  37. on creategFileNameList
  38.   if not voidp(gFileNameList) then
  39.     exit
  40.   end if
  41.   set gFileNameList to list("camera handling.txt", "shooting tips.txt", "exposure.txt", "lenses.txt", "the camera.txt", "the way we see.txt", "using light.txt", "action.txt", "aerial.txt", "architecture.txt", "fashion.txt", "landscapes.txt", "portraits.txt", "reportage.txt", "still life.txt", "the studio.txt", "underwater.txt", "wildlife.txt", "editing.txt", "equipment checklist.txt", "legal matters.txt", "the professional.txt", "author.txt")
  42. end
  43.  
  44. on returnFromText
  45.   puppetSprite(2, 0)
  46.   puppetSprite(7, 0)
  47.   puppetSprite(8, 0)
  48.   puppetSprite(11, 0)
  49.   puppetSprite(9, 0)
  50.   puppetSprite(gSearchTextSpriteNum, 0)
  51.   puppetSprite(35, 0)
  52.   puppetSprite(12, 0)
  53.   puppetSprite(13, 0)
  54.   set gNeedToDisposeScroll to gMyScrollObj
  55.   set the visible of sprite 11 to 1
  56.   set the visible of sprite 10 to 1
  57.   play frame "start"
  58. end
  59.  
  60. on handBookScrollCallBack
  61.   put getCurrentPage(gMyScrollObj) into word 2 of field 52
  62. end
  63.  
  64. on doSearchMouseUp
  65.   set the mouseUpScript to EMPTY
  66.   dontPassEvent()
  67.   set the castNum of sprite 35 to the castNum of sprite 35 - 1
  68.   updateStage()
  69.   doSearch()
  70. end
  71.  
  72. on doSearch
  73.   if the editable of member gSearchTextCastNum = 0 then
  74.     set the editable of member gSearchTextCastNum to 1
  75.     set the text of cast gSearchTextCastNum to EMPTY
  76.     exit
  77.   end if
  78.   set key to the text of cast gSearchTextCastNum
  79.   if (key = EMPTY) or (key = " ") then
  80.     exit
  81.   end if
  82.   set textCastNum to the castNum of sprite 2
  83.   repeat while 1
  84.     if (gLastSearchKey = key) and (gSearchKeyChanged = 0) then
  85.       set foundLoc to offset(key, char gLastSearchLoc + length(key) to length(the text of cast textCastNum) of the text of cast textCastNum)
  86.       if foundLoc then
  87.         set foundLoc to foundLoc + gLastSearchLoc + length(key) - 1
  88.       end if
  89.     else
  90.       set foundLoc to offset(key, the text of cast textCastNum)
  91.     end if
  92.     if foundLoc then
  93.       if (gLastSearchKey <> EMPTY) and (gLastSearchLoc <> 0) then
  94.         set the foreColor of char gLastSearchLoc to gLastSearchLoc + length(gLastSearchKey) - 1 of member textCastNum to gColorOfLastFind
  95.       end if
  96.       set gColorOfLastFind to the foreColor of char foundLoc of member textCastNum
  97.       set gLastSearchLoc to foundLoc
  98.       set charPos to charPosToLoc(member textCastNum, foundLoc)
  99.       set locOffset to getAt(charPos, 2) - the scrollTop of member textCastNum
  100.       set fontHeight to linePosToLocV(member textCastNum, 2)
  101.       if (locOffset > 0) and (locOffset > the height of sprite 2) then
  102.         doScroll(gMyScrollObj, (locOffset / fontHeight) - 2, 0)
  103.       else
  104.         if locOffset <= 0 then
  105.           if getAt(charPos, 2) < the height of sprite 2 then
  106.             resetScroll(gMyScrollObj, textCastNum)
  107.           else
  108.             doScroll(gMyScrollObj, (locOffset / fontHeight) - 2, 0)
  109.           end if
  110.         end if
  111.       end if
  112.       updateThumb(gMyScrollObj)
  113.       if gNeedToCallSearch then
  114.         set the visible of sprite 2 to 1
  115.         cursor(-1)
  116.       end if
  117.       set gLastSearchKey to key
  118.       set endChar to foundLoc + length(key) - 1
  119.       repeat with ix = 1 to 2
  120.         startTimer()
  121.         set the foreColor of char foundLoc to endChar of member textCastNum to gSearchHiliteColor
  122.         repeat while the timer < 5
  123.         end repeat
  124.         startTimer()
  125.         set the foreColor of char foundLoc to endChar of member textCastNum to gColorBlack
  126.         repeat while the timer < 5
  127.         end repeat
  128.       end repeat
  129.       set the foreColor of char foundLoc to endChar of member textCastNum to gSearchHiliteColor
  130.       exit repeat
  131.       next repeat
  132.     end if
  133.     if searchEntireHandbook() then
  134.       set foundOne to 0
  135.       set thisTextFileIndex to gTextFileNameIndex
  136.       set the editableText of sprite gSearchTextSpriteNum to 0
  137.       cursor(4)
  138.       set the editableText of sprite gSearchTextSpriteNum to 1
  139.       repeat while 1
  140.         set thisTextFileIndex to thisTextFileIndex + 1
  141.         if thisTextFileIndex > count(gFileNameList) then
  142.           set thisTextFileIndex to 1
  143.         end if
  144.         if thisTextFileIndex = gTextFileNameIndex then
  145.           if (gLastSearchKey = key) and (gSearchKeyChanged = 0) then
  146.           else
  147.             set gSearchKeyChanged to 0
  148.             cursor(-1)
  149.             beep(1)
  150.             exit
  151.           end if
  152.         end if
  153.         set fileName to getAt(gFileNameList, thisTextFileIndex)
  154.         set the text of cast 47 to the text of cast fileName
  155.         set foundOne to offset(key, the text of cast 47)
  156.         if foundOne then
  157.           exit repeat
  158.         end if
  159.       end repeat
  160.       if foundOne then
  161.         if gLastSearchLoc <> 0 then
  162.           set the foreColor of char gLastSearchLoc to gLastSearchLoc + length(gLastSearchKey) - 1 of member textCastNum to gColorBlack
  163.         end if
  164.         if thisTextFileIndex <> gTextFileNameIndex then
  165.           set gNeedToDisposeScroll to gMyScrollObj
  166.           set gMyScrollObj to EMPTY
  167.           set gTextFileNameIndex to thisTextFileIndex
  168.           set the visible of sprite 2 to 0
  169.           activateText()
  170.           set gNeedToCallSearch to 1
  171.           set gSearchKeyChanged to 1
  172.           set gLastSearchLoc to 0
  173.           go("text")
  174.           exit
  175.         else
  176.           set gSearchKeyChanged to 1
  177.           set gLastSearchLoc to 0
  178.         end if
  179.       end if
  180.       cursor(-1)
  181.       next repeat
  182.     end if
  183.     if (gLastSearchKey = key) and (gSearchKeyChanged = 0) then
  184.       if (gLastSearchKey <> EMPTY) and (gLastSearchLoc <> 0) then
  185.         set the foreColor of char gLastSearchLoc to gLastSearchLoc + length(gLastSearchKey) - 1 of member textCastNum to gColorBlack
  186.       end if
  187.       set gSearchKeyChanged to 1
  188.       set gLastSearchLoc to 0
  189.       next repeat
  190.     end if
  191.     beep(1)
  192.     exit repeat
  193.   end repeat
  194.   set gSearchKeyChanged to 0
  195. end
  196.  
  197. on doSearchMouseDown
  198.   set the castNum of sprite 35 to the castNum of sprite 35 + 1
  199.   updateStage()
  200.   set the mouseUpScript to "doSearchMouseUp"
  201. end
  202.  
  203. on searchEntireHandbook
  204.   return gSearchChapterOnly = 0
  205. end
  206.  
  207. on newWordSelected glossaryIndex
  208.   set theCastNum to the number of member line glossaryIndex of the text of cast "Glossary List"
  209.   repeat with boldLength = 1 to the number of chars in the text of cast theCastNum
  210.     if (the textStyle of char boldLength of member theCastNum contains "bold") = 0 then
  211.       exit repeat
  212.     end if
  213.   end repeat
  214.   set boldLength to boldLength - 1
  215.   repeat while 1
  216.     set ch to char boldLength of the text of cast theCastNum
  217.     if (ch <> " ") and (ch <> "-") then
  218.       exit repeat
  219.     end if
  220.     set boldLength to boldLength - 1
  221.   end repeat
  222.   set textStart to boldLength + 1
  223.   repeat while 1
  224.     set ch to char textStart of the text of cast theCastNum
  225.     if (ch <> " ") and (ch <> "-") then
  226.       exit repeat
  227.     end if
  228.     set textStart to textStart + 1
  229.   end repeat
  230.   set the textStyle of member 56 to "plain"
  231.   set the text of cast 56 to char textStart to length(the text of cast theCastNum) of the text of cast theCastNum
  232.   set the text of cast 51 to char 1 to boldLength of the text of cast theCastNum
  233.   showHideGlossaryBox(1)
  234.   cursor(-1)
  235. end
  236.  
  237. on showHideGlossaryBox showHide
  238.   if showHide = 1 then
  239.     set the mouseDownScript to "glossaryMouseDown"
  240.   else
  241.   end if
  242.   puppetSprite(40, showHide)
  243.   if (showHide = 1) and (the machineType >= 256) then
  244.     set the locV of sprite 40 to the locV of sprite 40 + 6
  245.     updateStage()
  246.   end if
  247.   set the visible of sprite 33 to showHide
  248.   set the visible of sprite 39 to showHide
  249.   set the visible of sprite 40 to showHide
  250.   if showHide = 1 then
  251.     set gGlosBoxUpTime to the ticks
  252.   end if
  253. end
  254.  
  255. on glossaryMouseDown
  256.   set the mouseUpScript to "blockMouseUp"
  257.   if the ticks > (gGlosBoxUpTime + 15) then
  258.     set the mouseDownScript to EMPTY
  259.     dontPassEvent()
  260.     showHideGlossaryBox(0)
  261.   end if
  262.   dontPassEvent()
  263. end
  264.  
  265. on blockMouseUp
  266.   set the mouseUpScript to EMPTY
  267.   dontPassEvent()
  268. end
  269.  
  270. on handBookPart
  271.   if marker(0) = label("text") then
  272.     return 2
  273.   else
  274.     return 1
  275.   end if
  276. end
  277.  
  278. on createGlossaryMarkerList
  279.   set glosListCastNum to the number of member "Glossary List"
  280.   set nWords to the number of lines in the text of cast glosListCastNum
  281.   set nFiles to count(gFileNameList)
  282.   repeat with file = 1 to nFiles
  283.     set thisFileList to EMPTY
  284.     set textCastNum to the number of member getAt(gFileNameList, file)
  285.     set numWordsFound to 0
  286.     repeat with ix = 1 to nWords
  287.       set thisWord to line ix of the text of cast glosListCastNum
  288.       case thisWord of
  289.         "Abstract":
  290.           next repeat
  291.         "Action":
  292.           next repeat
  293.         "Accessories":
  294.           next repeat
  295.         "Aerial photography":
  296.           next repeat
  297.         "Architecture":
  298.           next repeat
  299.         "Archaeology":
  300.           next repeat
  301.         "ASA":
  302.           next repeat
  303.         "Balance":
  304.           next repeat
  305.         "Bibliography":
  306.           next repeat
  307.         "Black-and-white":
  308.           next repeat
  309.         "Blur":
  310.           next repeat
  311.         "Cleaning":
  312.           next repeat
  313.         "Close-up":
  314.           next repeat
  315.         "DIN":
  316.           next repeat
  317.         "Editing":
  318.           next repeat
  319.         "Fashion":
  320.           next repeat
  321.         "Flash":
  322.           next repeat
  323.         "Flat":
  324.           next repeat
  325.         "Focus":
  326.           next repeat
  327.         "ISO":
  328.           next repeat
  329.         "Landscape":
  330.           next repeat
  331.         "LED":
  332.           next repeat
  333.         "Lenses":
  334.           next repeat
  335.         "Mountains":
  336.           next repeat
  337.         "Mode":
  338.           next repeat
  339.         "Portraits":
  340.           next repeat
  341.         "Rainforest":
  342.           next repeat
  343.         "Repro":
  344.           next repeat
  345.         "Shading":
  346.           next repeat
  347.         "Standard":
  348.           next repeat
  349.         "Speed":
  350.           next repeat
  351.         "Wildlife photography":
  352.           next repeat
  353.         otherwise:
  354.       end case
  355.       set ofst to offset(thisWord, the text of cast textCastNum)
  356.       if ofst then
  357.         set the textStyle of char ofst to ofst + length(thisWord) - 1 of member textCastNum to "underline"
  358.       end if
  359.     end repeat
  360.   end repeat
  361. end
  362.  
  363. on doPrintMouseUp
  364.   set the mouseUpScript to EMPTY
  365.   dontPassEvent()
  366.   set the castNum of sprite 13 to the castNum of sprite 13 - 1
  367.   updateStage()
  368.   if register(xtra("PrintOMatic"), "PMAT130-055-01161") <> 1 then
  369.     exit
  370.   end if
  371.   cursor(4)
  372.   set doc to new(xtra("PrintOMatic"))
  373.   if not objectp(doc) then
  374.     exit
  375.   end if
  376.   setDocumentName(doc, the text of cast the castNum of sprite 7)
  377.   setTextFont(doc, the textFont of member 13)
  378.   setTextJust(doc, "left")
  379.   set pageHeight to getPageHeight(doc)
  380.   set pageWidth to getPageWidth(doc)
  381.   set footerLocV to pageHeight - 26
  382.   setTextSize(doc, 10)
  383.   set footerString to the text of member "printFooter"
  384.   repeat with ix = 1 to the number of lines in footerString
  385.     set lineLocV to footerLocV + (10 * (ix - 1))
  386.     drawText(doc, line ix of footerString, point(0, lineLocV))
  387.   end repeat
  388.   newPage(doc)
  389.   newFrame(doc, rect(0, 0, pageWidth, footerLocV - 24), 0)
  390.   set headerString to the text of cast "printHeader" & the text of cast the castNum of sprite 7 & RETURN & RETURN
  391.   setTextSize(doc, 18)
  392.   append(doc, headerString, 1)
  393.   if the machineType >= 256 then
  394.     setTextSize(doc, 12)
  395.   else
  396.     setTextSize(doc, 10)
  397.   end if
  398.   append(doc, member 13, 1)
  399.   cursor(-1)
  400.   updateStage()
  401.   if doJobSetup(doc) then
  402.     print(doc)
  403.   end if
  404.   set doc to 0
  405. end
  406.  
  407. on goToChapter clickSprite, dotheUnderline
  408.   set gTextFileNameIndex to clickSprite - 10 + 1
  409.   if dotheUnderline then
  410.     doUnderline(clickSprite, 34, 1)
  411.   end if
  412.   cursor(4)
  413.   startTimer()
  414.   puppetSprite(2, 1)
  415.   puppetSprite(7, 1)
  416.   activateText()
  417.   puppetSprite(8, 0)
  418.   puppetSprite(34, 0)
  419.   prepForTextSection()
  420.   if dotheUnderline then
  421.     repeat while the timer < 60
  422.       updateStage()
  423.     end repeat
  424.   end if
  425.   if the locH of sprite 2 > 2000 then
  426.     set the locH of sprite 2 to the locH of sprite 2 - 2000
  427.   end if
  428.   set the castNum of sprite 7 to 70 + (gTextFileNameIndex - 1)
  429.   set the locH of sprite 7 to the locH of sprite 2 - 6
  430.   play frame "text"
  431. end
  432.  
  433. on prepForTextSection
  434.   set gLastSearchKey to EMPTY
  435.   set the text of cast gSearchTextCastNum to " "
  436.   if the machineType >= 256 then
  437.     set the textFont of member gSearchTextCastNum to "MS Sans Serif"
  438.   else
  439.     set the textFont of member gSearchTextCastNum to "Monaco"
  440.   end if
  441.   set the textSize of member gSearchTextCastNum to 9
  442.   set gLastSearchLoc to 0
  443.   set gSearchKeyChanged to 1
  444.   set the editable of member gSearchTextCastNum to 0
  445. end
  446.  
  447. on enableEditing
  448.   puppetSprite(44, 1)
  449.   set the ink of sprite 44 to 0
  450.   updateStage()
  451.   if (the editable of member gSearchTextCastNum = 0) and (gNeedToCallSearch = 0) then
  452.     set the editable of member gSearchTextCastNum to 1
  453.     set the text of cast gSearchTextCastNum to EMPTY
  454.   end if
  455. end
  456.